/*   1:    */ package org.jetbrains.rsa;
/*   2:    */ 
/*   3:    */

import com.intellij.licensecommon.util.a;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */ 
/*  12:    */ public class RSADecoder
/*  13:    */ {
/*  14:    */   private final BigInteger a;
/*  15:    */   private final BigInteger b;
/*  16:    */   private final BigInteger c;
/*  17:    */   private int d;
/*  18:    */   
/*  19:    */   public RSADecoder(BigInteger paramBigInteger1, BigInteger paramBigInteger2)
/*  20:    */   {
/*  21: 24 */     this(paramBigInteger1, paramBigInteger2, 36);
/*  22:    */   }
/*  23:    */   
/*  24:    */   public RSADecoder(BigInteger paramBigInteger1, BigInteger paramBigInteger2, int paramInt)
/*  25:    */   {
/*  26: 28 */     this.c = paramBigInteger2;
/*  27: 29 */     this.b = paramBigInteger1;
/*  28:    */     
/*  29: 31 */     int i = paramBigInteger2.bitLength();
/*  30: 32 */     int j = (int)Math.ceil(i / Math.log(paramInt) * Math.log(2.0D));
/*  31: 33 */     if (j % 5 != 0) {
/*  32: 34 */       j = (j / 5 + 1) * 5;
/*  33:    */     }
/*  34: 36 */     this.d = j;
/*  35: 37 */     this.a = new BigInteger(Integer.toString(paramInt));
/*  36:    */   }
/*  37:    */   
/*  38:    */   public byte[] decode(String paramString)
/*  39:    */     throws a
/*  40:    */   {
/*  41:    */     try
/*  42:    */     {
/*  43: 42 */       ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
/*  44: 43 */       BigInteger localBigInteger1 = BigInteger.ZERO;
/*  45: 44 */       int i = 0;
/*  46: 45 */       for (int j = 0; j < paramString.length(); j++)
/*  47:    */       {
/*  48: 46 */         char c1 = paramString.charAt(j);
/*  49: 47 */         if ((c1 != ' ') && (c1 != '\t') && (c1 != '\n') && (c1 != '-'))
/*  50:    */         {
/*  51: 48 */           localBigInteger1 = localBigInteger1.multiply(this.a).add(a(c1));
/*  52: 49 */           i++;
/*  53: 50 */           if (i == this.d)
/*  54:    */           {
/*  55: 51 */             BigInteger localBigInteger2 = localBigInteger1.modPow(this.b, this.c);
/*  56: 52 */             localByteArrayOutputStream.write(localBigInteger2.toByteArray());
/*  57: 53 */             localBigInteger1 = BigInteger.ZERO;
/*  58: 54 */             i = 0;
/*  59:    */           }
/*  60:    */         }
/*  61:    */       }
/*  62: 58 */       if (i != 0) {
/*  63: 58 */         throw new a();
/*  64:    */       }
/*  65: 60 */       localByteArrayOutputStream.close();
/*  66: 61 */       return localByteArrayOutputStream.toByteArray();
/*  67:    */     }
/*  68:    */     catch (IOException localIOException) {}
/*  69: 67 */     return new byte[0];
/*  70:    */   }
/*  71:    */   
/*  72:    */   private static BigInteger a(char paramChar)
/*  73:    */     throws a
/*  74:    */   {
/*  75:    */     int i;
/*  76: 72 */     if (('0' <= paramChar) && (paramChar <= '9')) {
/*  77: 73 */       i = paramChar - '0';
/*  78: 74 */     } else if (('A' <= paramChar) && (paramChar <= 'Z')) {
/*  79: 75 */       i = paramChar - 'A' + 10;
/*  80: 76 */     } else if (('a' <= paramChar) && (paramChar <= 'z')) {
/*  81: 77 */       i = paramChar - 'a' + 36;
/*  82: 78 */     } else if (('!' <= paramChar) && (paramChar <= ')')) {
/*  83: 79 */       i = paramChar - '!' + 62;
/*  84:    */     } else {
/*  85: 81 */       throw new a();
/*  86:    */     }
/*  87: 84 */     return BigInteger.valueOf(i);
/*  88:    */   }
/*  89:    */   
/*  90:    */   public String decodeString(String paramString)
/*  91:    */     throws a
/*  92:    */   {
/*  93:    */     try
/*  94:    */     {
/*  95: 89 */       return new String(decode(paramString), "UTF-8");
/*  96:    */     }
/*  97:    */     catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
/*  98: 93 */     return "";
/*  99:    */   }
/* 100:    */   
/* 101:    */   public Map<String, String> decodeProperties(String paramString)
/* 102:    */     throws a
/* 103:    */   {
/* 104: 98 */     HashMap localHashMap = new HashMap();
/* 105: 99 */     String str1 = decodeString(paramString);
/* 106:100 */     StringTokenizer localStringTokenizer = new StringTokenizer(str1, "\n", false);
/* 107:101 */     while (localStringTokenizer.hasMoreTokens())
/* 108:    */     {
/* 109:102 */       String str2 = localStringTokenizer.nextToken();
/* 110:103 */       String str3 = localStringTokenizer.nextToken();
/* 111:104 */       localHashMap.put(str2, str3);
/* 112:    */     }
/* 113:107 */     return localHashMap;
/* 114:    */   }
/* 115:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.rsa.RSADecoder

 * JD-Core Version:    0.7.0.1

 */